package es.tikitaka.domain.playoffs;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * 
 * @author Saúl Domínguez
 * @since 2010
 * @category PFC
 */

@Entity
@Table(name = "CALENDARIOPLAYOFFS")
public class CalendarioPlayoffs {

	private Integer id;
	private Set<Ronda> m_rondas;

	/**
	 * Constructor por defecto
	 */
	public CalendarioPlayoffs() {
		// TODO Auto-generated constructor stub
	}

	/*
	 * getters and setters
	 */

	/**
	 * 
	 * @return id Id del calendario de playoffs
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CPO_GEN")
	@SequenceGenerator(allocationSize = 1, name = "CPO_GEN", sequenceName = "CPO_SEQ")
	@Column(name = "X_CPO", nullable = false, precision = 10, scale = 0)
	public Integer getId() {
		return id;
	}

	/**
	 * 
	 * @param id
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * 
	 * @return m_rondas Conjunto de rondas que componen los playoffs
	 */
	@OneToMany(mappedBy = "calendario", fetch = FetchType.LAZY)
	public Set<Ronda> getM_rondas() {
		return m_rondas;
	}

	/**
	 * 
	 * @param m_rondas
	 */
	public void setM_rondas(Set<Ronda> m_rondas) {
		this.m_rondas = m_rondas;
	}

	/**
	 * Método equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof CalendarioPlayoffs)) {
			return false;
		}
		if (obj != null) {
			if (this.id == ((CalendarioPlayoffs) obj).getId()) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Método hashCode
	 */
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return super.hashCode();
	}
}
